package com.jhhc.StormSurgeForecast.StormSurge.ServiceImpl;

import com.jhhc.StormSurgeForecast.StormSurge.Pojo.Product.BDMS_PRODUCT_RESULT;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BdmsProductResult)表服务实现类
 *
 * @author makejava
 * @since 2023-04-04 15:07:07
 */
@Service("bdmsProductResultService")
public class BDMS_PRODUCT_RESULTServiceImpl implements com.jhhc.StormSurgeForecast.StormSurge.Service.BDMS_PRODUCT_RESULTService {
    @Resource
    private com.jhhc.StormSurgeForecast.StormSurge.Dao.BDMS_PRODUCT_RESULTMapper BDMSPRODUCTRESULTMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param prodid 主键
     * @return 实例对象
     */
    @Override
    public BDMS_PRODUCT_RESULT queryById(String prodid) {
        return this.BDMSPRODUCTRESULTMapper.queryById(prodid);
    }

    @Override
    public List<BDMS_PRODUCT_RESULT> queryByProjectId(Integer projectId, String infoId,Integer typhoonId) {
        return BDMSPRODUCTRESULTMapper.queryByProjectId(projectId, infoId,typhoonId);
    }

    @Override
    public List<BDMS_PRODUCT_RESULT> queryByProductId(Integer projectId, String infoId, String productId) {
        return BDMSPRODUCTRESULTMapper.queryByProductId(projectId, infoId, productId);
    }

    @Override
    public BDMS_PRODUCT_RESULT queryByProductIdInfoID(Integer projectId, String infoId, String productId) {
        return BDMSPRODUCTRESULTMapper.queryByProductIdInfoID(projectId, infoId, productId);
    }

    /**
     * 分页查询
     *
     * @param bdmsProductResult 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<BDMS_PRODUCT_RESULT> queryByPage(BDMS_PRODUCT_RESULT bdmsProductResult, PageRequest pageRequest) {
        long total = this.BDMSPRODUCTRESULTMapper.count(bdmsProductResult);
        return new PageImpl<>(this.BDMSPRODUCTRESULTMapper.queryAllByLimit(bdmsProductResult, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param bdmsProductResult 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(BDMS_PRODUCT_RESULT bdmsProductResult) {
        return  BDMSPRODUCTRESULTMapper.insert(bdmsProductResult);
    }

    /**
     * 修改数据
     *
     * @param bdmsProductResult 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_PRODUCT_RESULT update(BDMS_PRODUCT_RESULT bdmsProductResult) {
        this.BDMSPRODUCTRESULTMapper.update(bdmsProductResult);
        return this.queryById(bdmsProductResult.getProdid());
    }

    /**
     * 通过主键删除数据
     *
     * @param prodid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String prodid,String infoid) {
        return this.BDMSPRODUCTRESULTMapper.deleteById(prodid,infoid) > 0;
    }
}
